using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using yW5Lib;
using yWriter6.My.Resources;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmChart : Form
	{
		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("PicChart")]
		private PictureBox _PicChart;

		[CompilerGenerated]
		[AccessedThroughProperty("lblLegend3")]
		private Label _lblLegend3;

		[CompilerGenerated]
		[AccessedThroughProperty("lblLegend2")]
		private Label _lblLegend2;

		[CompilerGenerated]
		[AccessedThroughProperty("lblLegend1")]
		private Label _lblLegend1;

		[CompilerGenerated]
		[AccessedThroughProperty("lblLegend0")]
		private Label _lblLegend0;

		private Label[] lblLegend;

		private clsProject cProject;

		private bool Suppress;

		private bool Show0;

		private bool Show1;

		private bool Show2;

		private bool Show3;

		public virtual PictureBox PicChart
		{
			[CompilerGenerated]
			get
			{
				return _PicChart;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = PicChart_Click;
				PictureBox picChart = _PicChart;
				if (picChart != null)
				{
					picChart.Click -= value2;
				}
				_PicChart = value;
				picChart = _PicChart;
				if (picChart != null)
				{
					picChart.Click += value2;
				}
			}
		}

		public virtual Label lblLegend3
		{
			[CompilerGenerated]
			get
			{
				return _lblLegend3;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = lblLegend3_Click;
				Label lblLegend = _lblLegend3;
				if (lblLegend != null)
				{
					lblLegend.Click -= value2;
				}
				_lblLegend3 = value;
				lblLegend = _lblLegend3;
				if (lblLegend != null)
				{
					lblLegend.Click += value2;
				}
			}
		}

		public virtual Label lblLegend2
		{
			[CompilerGenerated]
			get
			{
				return _lblLegend2;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = lblLegend2_Click;
				Label lblLegend = _lblLegend2;
				if (lblLegend != null)
				{
					lblLegend.Click -= value2;
				}
				_lblLegend2 = value;
				lblLegend = _lblLegend2;
				if (lblLegend != null)
				{
					lblLegend.Click += value2;
				}
			}
		}

		public virtual Label lblLegend1
		{
			[CompilerGenerated]
			get
			{
				return _lblLegend1;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = lblLegend1_Click;
				Label lblLegend = _lblLegend1;
				if (lblLegend != null)
				{
					lblLegend.Click -= value2;
				}
				_lblLegend1 = value;
				lblLegend = _lblLegend1;
				if (lblLegend != null)
				{
					lblLegend.Click += value2;
				}
			}
		}

		public virtual Label lblLegend0
		{
			[CompilerGenerated]
			get
			{
				return _lblLegend0;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = lblLegend0_Click;
				Label lblLegend = _lblLegend0;
				if (lblLegend != null)
				{
					lblLegend.Click -= value2;
				}
				_lblLegend0 = value;
				lblLegend = _lblLegend0;
				if (lblLegend != null)
				{
					lblLegend.Click += value2;
				}
			}
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			PicChart = new System.Windows.Forms.PictureBox();
			lblLegend3 = new System.Windows.Forms.Label();
			lblLegend2 = new System.Windows.Forms.Label();
			lblLegend1 = new System.Windows.Forms.Label();
			lblLegend0 = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)PicChart).BeginInit();
			SuspendLayout();
			PicChart.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			PicChart.BackColor = System.Drawing.SystemColors.Window;
			PicChart.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			PicChart.Cursor = System.Windows.Forms.Cursors.Default;
			PicChart.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			PicChart.ForeColor = System.Drawing.SystemColors.ControlText;
			PicChart.Location = new System.Drawing.Point(13, 13);
			PicChart.Name = "PicChart";
			PicChart.RightToLeft = System.Windows.Forms.RightToLeft.No;
			PicChart.Size = new System.Drawing.Size(681, 405);
			PicChart.TabIndex = 0;
			PicChart.TabStop = false;
			lblLegend3.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			lblLegend3.BackColor = System.Drawing.SystemColors.Control;
			lblLegend3.Cursor = System.Windows.Forms.Cursors.Default;
			lblLegend3.Font = new System.Drawing.Font("Segoe UI", 10f);
			lblLegend3.ForeColor = System.Drawing.SystemColors.ControlText;
			lblLegend3.Location = new System.Drawing.Point(337, 431);
			lblLegend3.Name = "lblLegend3";
			lblLegend3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			lblLegend3.Size = new System.Drawing.Size(98, 20);
			lblLegend3.TabIndex = 4;
			lblLegend3.Text = "Legend";
			lblLegend2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			lblLegend2.BackColor = System.Drawing.SystemColors.Control;
			lblLegend2.Cursor = System.Windows.Forms.Cursors.Default;
			lblLegend2.Font = new System.Drawing.Font("Segoe UI", 10f);
			lblLegend2.ForeColor = System.Drawing.SystemColors.ControlText;
			lblLegend2.Location = new System.Drawing.Point(228, 431);
			lblLegend2.Name = "lblLegend2";
			lblLegend2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			lblLegend2.Size = new System.Drawing.Size(96, 20);
			lblLegend2.TabIndex = 3;
			lblLegend2.Text = "Legend";
			lblLegend1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			lblLegend1.BackColor = System.Drawing.SystemColors.Control;
			lblLegend1.Cursor = System.Windows.Forms.Cursors.Default;
			lblLegend1.Font = new System.Drawing.Font("Segoe UI", 10f);
			lblLegend1.ForeColor = System.Drawing.SystemColors.ControlText;
			lblLegend1.Location = new System.Drawing.Point(118, 431);
			lblLegend1.Name = "lblLegend1";
			lblLegend1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			lblLegend1.Size = new System.Drawing.Size(97, 20);
			lblLegend1.TabIndex = 2;
			lblLegend1.Text = "Legend";
			lblLegend0.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			lblLegend0.BackColor = System.Drawing.SystemColors.Control;
			lblLegend0.Cursor = System.Windows.Forms.Cursors.Default;
			lblLegend0.Font = new System.Drawing.Font("Segoe UI", 10f);
			lblLegend0.ForeColor = System.Drawing.SystemColors.ControlText;
			lblLegend0.Location = new System.Drawing.Point(13, 431);
			lblLegend0.Name = "lblLegend0";
			lblLegend0.RightToLeft = System.Windows.Forms.RightToLeft.No;
			lblLegend0.Size = new System.Drawing.Size(92, 20);
			lblLegend0.TabIndex = 1;
			lblLegend0.Text = "Legend";
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 14f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.ClientSize = new System.Drawing.Size(708, 463);
			base.Controls.Add(PicChart);
			base.Controls.Add(lblLegend3);
			base.Controls.Add(lblLegend2);
			base.Controls.Add(lblLegend1);
			base.Controls.Add(lblLegend0);
			Cursor = System.Windows.Forms.Cursors.Default;
			DoubleBuffered = true;
			Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			base.Location = new System.Drawing.Point(2, 23);
			MinimumSize = new System.Drawing.Size(543, 380);
			base.Name = "frmChart";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			Text = "Scene Ratings Chart (Excludes unused scenes and chapters)";
			((System.ComponentModel.ISupportInitialize)PicChart).EndInit();
			ResumeLayout(false);
		}

		public frmChart(clsProject ProjectClass)
		{
			base.ClientSizeChanged += frmChart_ClientSizeChanged;
			base.FormClosing += frmChart_FormClosing;
			base.Load += frmChart_Load;
			Suppress = true;
			Show0 = true;
			Show1 = true;
			Show2 = true;
			Show3 = true;
			InitializeComponent();
			try
			{
				lblLegend = new Label[4]
				{
					lblLegend0,
					lblLegend1,
					lblLegend2,
					lblLegend3
				};
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				ProjectData.ClearProjectError();
			}
			cProject = ProjectClass;
		}

		private void DrawChart(int FieldIndex, Color LineColour, ref Graphics G)
		{
			try
			{
				Label obj = lblLegend[FieldIndex - 1];
				obj.Text = cProject.get_FieldTitle(FieldIndex);
				obj.ForeColor = LineColour;
				Pen pen = new Pen(LineColour);
				int usedSceneCount = cProject.UsedSceneCount;
				if (usedSceneCount != 0)
				{
					float num = (float)((double)(PicChart.Width - 10) / (double)usedSceneCount);
					float num2 = (float)((double)(PicChart.Height - 10) / 10.0);
					PicChart.Font = new Font("Arial", 6f);
					IEnumerator enumerator = default(IEnumerator);
					try
					{
						enumerator = cProject.AllChaptersUsedNoInfoType().GetEnumerator();
						int num3 = default(int);
						float num4 = default(float);
						float num6 = default(float);
						while (enumerator.MoveNext())
						{
							clsChapter clsChapter = (clsChapter)enumerator.Current;
							int sceneCount = clsChapter.SceneCount;
							for (int i = 1; i <= sceneCount; i++)
							{
								clsScene clsScene = cProject.get_SceneByID(clsChapter.get_SceneIDByIndex(i));
								if (!clsScene.Unused)
								{
									num3++;
									float num5 = num4;
									float num7 = num6;
									num4 = 5f + num * (float)num3;
									num6 = (float)(PicChart.Height - 10) - num2 * (float)((clsSceneBase)clsScene).get_Field(FieldIndex);
									if (num7 == 0f)
									{
										num7 = num6;
									}
									if (num5 == 0f)
									{
										num5 = num4;
									}
									G.DrawLine(pen, num5, num7, num4, num6);
								}
							}
							G.DrawLine(pen, num4, PicChart.Height - 10 + 1, num4, PicChart.Height - 10 + 3);
						}
					}
					finally
					{
						if (enumerator is IDisposable)
						{
							(enumerator as IDisposable).Dispose();
						}
					}
				}
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				ProjectData.ClearProjectError();
			}
		}

		private void frmChart_ClientSizeChanged(object sender, EventArgs e)
		{
			if (base.WindowState != FormWindowState.Minimized)
			{
				DrawAll();
			}
		}

		private void frmChart_FormClosing(object sender, FormClosingEventArgs e)
		{
			clsShared.cSettings.StoreWindowSettings("Chart", this);
		}

		private void frmChart_Load(object eventSender, EventArgs eventArgs)
		{
			base.Icon = Resources.yWriter5_Ico;
			Suppress = false;
			clsSettings cSettings = clsShared.cSettings;
			Form Form = this;
			cSettings.ReadWindowSettings("Chart", ref Form);
			DrawAll();
		}

		private void DrawAll()
		{
			if (!Suppress)
			{
				try
				{
					Bitmap image = new Bitmap(PicChart.ClientSize.Width, PicChart.ClientSize.Height);
					Graphics G = Graphics.FromImage(image);
					if (Show0)
					{
						DrawChart(1, cColours.BlueInk, ref G);
					}
					else
					{
						lblLegend[0].Text = "---";
					}
					if (Show1)
					{
						DrawChart(2, cColours.DarkGreenInk, ref G);
					}
					else
					{
						lblLegend[1].Text = "---";
					}
					if (Show2)
					{
						DrawChart(3, cColours.RedInk, ref G);
					}
					else
					{
						lblLegend[2].Text = "---";
					}
					if (Show3)
					{
						DrawChart(4, cColours.GreyInk, ref G);
					}
					else
					{
						lblLegend[3].Text = "---";
					}
					PicChart.Image = image;
					G.Dispose();
				}
				catch (Exception ex)
				{
					ProjectData.SetProjectError(ex);
					Exception ex2 = ex;
					ProjectData.ClearProjectError();
				}
			}
		}

		private void lblLegend0_Click(object sender, EventArgs e)
		{
			Show0 = !Show0;
			DrawAll();
		}

		private void lblLegend1_Click(object sender, EventArgs e)
		{
			Show1 = !Show1;
			DrawAll();
		}

		private void lblLegend2_Click(object sender, EventArgs e)
		{
			Show2 = !Show2;
			DrawAll();
		}

		private void lblLegend3_Click(object sender, EventArgs e)
		{
			Show3 = !Show3;
			DrawAll();
		}

		private void PicChart_Click(object sender, EventArgs e)
		{
		}
	}
}
